SOLR-17697 Ref-guide documentation for new picocli commands#4271
Conversation
| // end::picocli-generated-man-section-commands[] | ||
|
|
||
| // tag::picocli-generated-man-section-exit-status[] | ||
| // end::picocli-generated-man-section-exit-status[] |
There was a problem hiding this comment.
We could obviously add @picocli annotations to document exit status for all tools asl well... Not sure how useful it is. Guess for the assert tool it would be useful, and for the stop tool to signal success...
| == Command Reference | ||
|
|
||
| The table below lists all available `bin/solr` commands. | ||
| Commands marked with (✓) have dedicated reference pages auto-generated from source annotations; others are documented inline below. |
There was a problem hiding this comment.
This section is temporary, not intended for release. I suppose this entire "landing page" needs to be re-written in a way that gives a good overview, without touching the details.
Question: Currently we have usage examples hand written in the ref-guide page. We could instead add usage examples for each tool either in the description field or footer field, or some custom annotation that we invent and tie in when generating docs:
@Command(
name = "myapp",
footerHeading = "%nExamples:%n",
footer = {
" # Basic usage",
" myapp --input foo.txt",
"",
" # With options",
" myapp --input foo.txt --verbose"
}
)I think perhaps using footer for this purpose is a good approach, this way also the --help for each tool will print usage examples. I think we can sacrifice the current refguide URL link we have in all the footers. It can perhaps be included on the main bin/solr command only.
There was a problem hiding this comment.
I like that idea. And the ref guide link is a bit of an oddity too anyway...
There was a problem hiding this comment.
We have been caught many times with ref guide differences from reality in the docs.
Nice! |
|
I want to say how much i like the zk nesting of sub commands. I started hacking on a |
…generation # Conflicts: # solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java # solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java # solr/core/src/java/org/apache/solr/cli/StatusTool.java # solr/core/src/java/org/apache/solr/cli/UpdateACLTool.java # solr/core/src/java/org/apache/solr/cli/ZkLsTool.java # solr/core/src/java/org/apache/solr/cli/ZkRmTool.java
Remove some hacks in gradle
|
Note that the global options |
|
|
||
| The only reason you will likely need to change the `antora.template.yml` is if you are introducing new variables for dependency versions. | ||
|
|
||
| == Auto-generated CLI Reference Pages |
There was a problem hiding this comment.
So, it's funny what things we check into source code that are generated and what are not (SolrJ endpoints from OpenAPI annotations for example). I just ran the task to generate the cli pages and it went super fast.. What value are we getting by checking them into source code? I don't have a super strong opinon one way or the other, more of an observation.
There was a problem hiding this comment.
Checking them in gives less "magic" and will also help surface unintended CLI contract edites in tools as the PR will fail precommit, needing to re-generate docs. Then one can review if the change was intended and back-compat before calling generateCliDocs...
| === Adding docs for a new tool | ||
|
|
||
| The new command will automatically appear in the generated pages and the navigation when running `gradlew generateCliDocs`. | ||
| You will need to tie it in to the `solr-control-script-reference.adoc` yourself. |
There was a problem hiding this comment.
Hopefully we rework solr-control-script-reference.adoc.... I see the table you added flagging which have autogenerated links. At a minimum, we should eliminate the listing of parameters to each command that exist in solr-control-script-reference.adoc and lean into using the generated docs. I don't know if that is part of this PR or it's own?
There was a problem hiding this comment.
Yes, the control-script-reference page has still more work to do. I'll add another check box in the feature-branch PR for it...
| exitCodeListHeading = "%nExit Codes:%n", | ||
| exitCodeList = { | ||
| "0:Collection or core deleted successfully.", | ||
| "1:Failed to delete; collection or core may not exist, or Solr may not be running." |
There was a problem hiding this comment.
wow... actual documentation of return codes! Helpful for folks writing automation.
There was a problem hiding this comment.
Absolutely. Made me think about return codes a bit as well. Such as for solr stop. It will actually return 1 (failure) if solr was not already running. But perhaps it should be differentiated to returning
- 0 if solr was running and successfully stopped
- 1 if solr was not running
- 2 if there was a syntax error in the command
- 3 if solr was running but we could not stop it
This is out of scope for this PR, but I'd love it if documenting exit codes in picocli would lead to other PRs to clean up in our exit code behavior...
| }, | ||
| footerHeading = "%nExamples:%n", | ||
| footer = { | ||
| " # Create a collection in SolrCloud mode", |
There was a problem hiding this comment.
do we still need to litter in SolrCloud mode everywhere? Or... Create a collection in SolrCloud mode and a core in User Managed mode? (sigh)...
There was a problem hiding this comment.
i wonder..... Should we introduce a bin/solr core create -c myCore and keep bin/solr create -c myCollection as solr cloud? are there use cases where folks want to work with a specific core while in solr cloud mode? This is a bit off topic.
There was a problem hiding this comment.
Good catch, the createTool is also for standalone. So this should probably be fixed.
I was impatient and mergd doc branch into feature branch. So will include this in a fixup commit shortly
| @CommandLine.Command(name = "start", description = "Starts Solr in standalone or SolrCloud mode.") | ||
| @CommandLine.Command( | ||
| name = "start", | ||
| description = "Starts Solr in standalone or SolrCloud mode.", |
There was a problem hiding this comment.
standalone --> user-managed ? the switch is --user-managed. I dislike the term user managed, but it is what we agreed...... "Disagree and commit' ;-)
There was a problem hiding this comment.
Will fix in followup commit to feature branch. I also caught a bug in the last example, where Claude had constructed this impossible command:
# Start in standalone mode with an external ZooKeeper
bin/solr start --user-managed -z localhost:2181/solrHAHA - user managed with zookeeper 🤣


This is a WIP POC for auto generating CLI ref-guide docs for the new picoCli instrumented tools. The docs are auto generated using PicoCLI's
ManPageGenerator, one ref-guide page per tool. Menus are also updated, and tools are cross-linked. The existing landig page "Solr Control Script Reference" is reduced from a huge all-in-one page to an overview page that introduces the CLI and links to the generated man-pages. This way, our docs will always stay in sync with the actual@picocliannotations in the code.There are two gradle tasks added in this PR:
generateCliDocs- Regenerate CLI reference pages in pages/cli/ from picocli annotations.checkCliDocsUpToDate- Verify that pages/cli/ CLI docs are in sync with picocli annotations - runs on checkScreenshot:

This is a draft, mostly AI generated, not reviewed in full. Need discussion about how we want the docs to be.
https://issues.apache.org/jira/browse/SOLR-17697